//package com.easipass.epug.dao;
//
//import com.easipass.epug.entity.User;
//import org.hibernate.Query;
//import org.hibernate.SessionFactory;
//import org.springframework.stereotype.Repository;
//
//import javax.annotation.Resource;
//import java.util.List;
//
///**
// * Created by Wangxuyang on 16/6/5.
// */
//@Repository("userDao")
//public class UserDaoImp implements UserDao {
//    @Resource
//    private SessionFactory sessionFactory;
////    public SessionFactory getSessionFactory() {
////        return sessionFactory;
////    }
////    public void setSessionFactory(SessionFactory sessionFactory) {
////        this.sessionFactory = sessionFactory;
////    }
//
//    public void addUser(User u) {
//        this.sessionFactory.openSession().save(u);
//    }
//
//    @SuppressWarnings("unchecked")
//    public List<User> getAllUsers() {
//        String sql = "select * from user";
//        Query query = sessionFactory.getCurrentSession().createQuery(sql);
//        return query.list();
//    }
//
//    public boolean del(String id) {
//        String sql = "delete from user where id=?";
//        Query query = sessionFactory.getCurrentSession().createQuery(sql);
//        query.setInteger(0,Integer.parseInt(id));
//        return query.executeUpdate()>0;
//    }
//
//    public void update(User u) {
//        String sql = "update user set name=? where id=?";
//        Query query = sessionFactory.getCurrentSession().createQuery(sql);
//        query.setInteger(0,u.getId());
//        query.setString(1,u.getName());
//        query.executeUpdate();
//    }
//
//    @SuppressWarnings("unchecked")
//    public List<User> getUserById(String id) {
//        String sql = "from user where id=?";
//        Query query = sessionFactory.getCurrentSession().createQuery(sql);
//        query.setInteger(0,Integer.parseInt(id));
//        return query.list();
//    }
//}
